﻿using System;
using System.Net.Mail;
using System.Text;

namespace AcademicPlanner.Framework.Helpers
{
	/// <summary>
	/// EmailHelper provides static helper methods to send out email messages.
	/// </summary>
	/// <version>1.0</version>
	/// <since>1.0</since>
	public static class EmailHelper
	{
		private static readonly string hostName = "localhost";


		/// <summary>
		/// Sends out a text email message.
		/// </summary>
		/// <param name="pFrom">The sender's address.</param>
		/// <param name="pTo">The receiver's address.</param>
		/// <param name="pSubject">The subject of the message.</param>
		/// <param name="pBody">The body of the message.</param>
		/// <returns>Whether the message was sent successfully or not.</returns>
		/// <version>1.0</version>
		/// <since>1.0</since>
		public static bool SendTextEmail(string pFrom, string pTo, string pSubject, string pBody)
		{
			try
			{
				var vClient = new SmtpClient(hostName);
				vClient.Send(pFrom, pTo, pSubject, pBody);
			}
			catch(SmtpException)
			{
				// TODO: UNCOMMENT WHEN ON PRODUCTION.
				//return false;
			}
			
			return true;
		}
	}
}
